﻿package  src
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	public class Main extends MovieClip
	{
		public static var stage:Stage;
		public static var root:DisplayObject;
		
		private var factory:GameFactory;
		private var game:IGame;
		
		
		//Constructor
		public function Main()
		{			
			stop();
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		

		private function init(e:Event) : void
        {
			e.stopPropagation();
		
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.showDefaultContextMenu =  false;

			createApplication()
		};
		
		private function createApplication():void 
		{
			Main.stage = this.stage;
			Main.root = this;
			
			//stage.addEventListener(KeyboardEvent.KEY_UP, keyListener);
			
			factory = new GameFactory();
			game = factory.createGame();
			game.start();
			this.addChild(game.container);
		}
		


	}//class

}//package


